#pragma once

#include "Common/Stream.h"
#include "Common/TimeUtil.h"

struct GamePacket
{
	GamePacket( UInt64 pid, Stream& st )
		: _time( TimeUtil::Now() ), _pid( pid )
	{
		UInt16 buf[3] = { 0, 0, 0 };
		memcpy( buf, &st[0], 6 );
		_cmd = buf[2];
		_len = buf[0];
		_buffer.resize( st.bodysize() );
		memcpy( &_buffer[0], st.body(), st.bodysize() );
	}

	UInt32	_time;
	UInt64	_pid;	//0:all 
	UInt16	_cmd;
	UInt16  _len;
	std::vector<UInt8> _buffer;
};

struct GamePlayer
{
	UInt64		_id;
	std::string	_name;
	std::string	_nick;
	UInt8		_pos;

	GamePlayer()
		: _id(0), _pos(0)
	{}
};

class Stream;
class GameSimulator;
class GameReport
{
public:
	GameReport();
	~GameReport();

public:
	bool prepare(GameSimulator *);
	bool add(UInt64, Stream&);
	void end();

protected:
	std::vector<UInt32> getReportIds();
	
public:
	UInt32	_rid;
	UInt32	_time;
	GameSimulator * _gs;
	std::list<GamePacket> _packets;
};